import { Component, OnInit } from '@angular/core';
import { Singlepage } from '../../model/singlepage';
import { SinglepageService } from '../../service/singlepage.service';
import { Router } from '@angular/router';

@Component({
  selector: 'app-singlepagelist',
  templateUrl: './singlepagelist.component.html',
  styleUrls: ['./singlepagelist.component.css']
})
export class SinglepagelistComponent implements OnInit {
  sl:Array<Singlepage>;
  parm:string;
  singlepage:Singlepage;

  constructor(
    private singlepageservice:SinglepageService,
    private router:Router
  ) { 
    this.sl=new Array();
    // for(let i=0;i<3;i++){
    //   let s=new Singlepage();
    //   s.singlepageid="id"+i;
    //   s.img="http://www.w3.org/2000/svg";
    //   s.summary="摘要"+i;
    //   s.title="标题"+i;
    //   s.detail="详细内容"+i;
    //   this.sl.push(s);
    // }
  }

  ngOnInit() {
    this.sl=new Array();
    this.loadSinglelist();
  }

  private loadSinglelist(){
    this.sl=new Array();
    this.singlepageservice.getSinglepageList()
    .then((data:any)=>{
      this.sl=data;
      console.log(this.sl[0].img);
    })
  }

  showSinglepage(id:string){
    this.router.navigate(['showlist']);
  
  }
  

}
